package com.cwh.taskcenter.domain.engine.rule.function;

import com.alibaba.qlexpress4.runtime.Parameters;
import com.alibaba.qlexpress4.runtime.QContext;
import com.alibaba.qlexpress4.runtime.Value;
import com.alibaba.qlexpress4.runtime.function.CustomFunction;
import com.cwh.taskcenter.domain.engine.rule.context.AbstractContext;
import com.cwh.taskcenter.domain.engine.rule.context.TaskRuleContext;

/**
 * @author cwh
 */
@QLExpressFunction("hello")
public class HelloFunction implements CustomFunction {
    @Override
    public Object call(QContext qContext, Parameters parameters) throws Throwable {
        TaskRuleContext context = (TaskRuleContext)qContext.attachment().get("context");
        if (context == null) {
            return false;
        }
        context.setProgress(100);
        Value value = parameters.get(0);
        if (value != null) {
            System.out.println(value.get());
        }
        System.out.println("hello");
        return true;
    }
}
